//引入封装好的接口
import {getRoleList} from '../../../util/axios'
const state = {
    roleList:[] //角色列表
} 
const getters = {
    getRoleList(state){
        return state.roleList
    }
}
const mutations ={
    //封装修改state的mutation
    REQ_ROLELIST(state,payload){
        state.roleList = payload
    }
} 
const actions = {
    //封装一个修改角色列表的行动
    getRoleListAction({commit}){
        //调用接口
        getRoleList()
        .then(res=>{
           if(res.data.code==200){
               //提交一个mutation
               commit('REQ_ROLELIST',res.data.list)
           }
        })
    }
} 


export default {
    state,
    getters,
    mutations,
    actions,
    namespaced:true
}